/* @(#)GSAuditManualAuditAction.java    
*
* Project: BUS
*
* Modify Information:
* =============================================================================
*   Author       Date       Description
*   ------------ ---------- ---------------------------------------------------
*   Simonyi Peng 2006-2-7    建立
*
* Copyright Notice:
* =============================================================================
*    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
*        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
*        Haidian District, Beijing ,100081, China All rights reserved.
*
*    This software is the confidential and proprietary information of
*        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
*        You shall not disclose such Confidential Information and shall use it
*        only in accordance with the terms of the license agreement you entered
*        into with HiTRUST.
*
* Warning:
* =============================================================================
* 
*/
package com.hitrust.gs.action;

import java.util.ArrayList;

import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.net.*;
import com.hitrust.gs.service.*;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.bean.*;

/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSAuditManualAuditAction extends GSBaseAction {
	public String execute(GSBaseForm aForm) throws Exception {
	    
	    GSAuditManager manager = new GSAuditManager();
	    GSAuditDAO dao = new GSAuditDAO();
	    String date = aForm.getRequest().getParameter("currentdate");
	    
	    //4.0: 初始化对帐结果和对帐信息
	    try{
	        dao.initAuditResult(date);
	    }catch(GSException e){
	        GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
	    }
        //4.1: 对帐ALLITEMS
        try{
            manager.auditAllItems(GSAuditConstants.getFile(date,GSAuditConstants.ALLITEMS),date);            
        }catch(GSException e){
            GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
        }
        //4.2: 对帐ITEMSDOING
        try{
            manager.auditItemsDoing(GSAuditConstants.getFile(date,GSAuditConstants.ITEMSDOING),date);            
        }catch(GSException e){
            GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
        }
        //4.3: 对帐ITEMSREFUSED
        try{
            manager.auditItemsRefused(GSAuditConstants.getFile(date,GSAuditConstants.ITEMSREFUSED),date);            
        }catch(GSException e){
            GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
        }
        // 4.4: 对帐ITEMSFINISHED
        try{
            manager.auditItemsFinished(GSAuditConstants.getFile(date,GSAuditConstants.ITEMSFINISHED),date);            
        }catch(GSException e){
            GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
        }
        //4.5: 对帐ITEMSCANCELED
        try{
            manager.auditItemsCanceled(GSAuditConstants.getFile(date,GSAuditConstants.ITEMSCANCEL),date);            
        }catch(GSException e){
            GSLogWriter.error(GSException.E00001,GSException.E00001_MSG);
        }
        
	    
	    GSAuditManager auditm = new GSAuditManager();
	    
	    GSAuditResultBean tBean = (GSAuditResultBean)auditm.getAuditResult(date);
	    
	    aForm.getRequest().setAttribute("auditresult",tBean);
	    
	    return GSBaseConstants.FORWARD_SUCCESS;
        
	}
}
